package com.xing.dao.role;

import com.xing.dao.BaseDao;
import com.xing.pojo.Role;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RoleDaoImpl implements RoleDao{

    @Override
    public List<Role> getRoleList() throws SQLException, ClassNotFoundException {
        ResultSet resultSet = null;
        ArrayList<Role> roleList = new ArrayList<>();
        String sql = "select * from smbms_role";
        Object[] objects = null;
        BaseDao baseDao = new BaseDao();
        resultSet = baseDao.execute(sql, objects);
        while (resultSet.next()){
            Role role = new Role();
            role.setId(resultSet.getInt("id"));
            role.setRoleCode(resultSet.getString("roleCode"));
            role.setRoleName(resultSet.getString("roleName"));
            roleList.add(role);
        }
        baseDao.closeAll();
        return roleList;
    }
}
